package com.kt.thread.demo; /**
 * Created by tangwy on 2016/9/14.
 */


/**
 * Suspend死锁例子
 */
public class TestSuspendThread {
    private static Object lock=new Object();
    private static SuspendThread st1=new SuspendThread();
    private static SuspendThread st2=new SuspendThread();
    public static void test()throws Exception{
        st1.start();
        Thread.sleep(1000);
        st2.start();
        st1.resume();
        st2.resume();
        //st1.join();
        //st2.join();
    }

    private static class SuspendThread  extends Thread{
        @Override
        public void run() {
            synchronized (lock){
                System.out.println("线程:"+Thread.currentThread().getName());
                Thread.currentThread().suspend();
                System.out.println("线程:" + Thread.currentThread().getName()+"resume");
            }
        }
    }


}
